//
//  Smarthings.m
//  Smarthings
//
//  Created by Stefan Tsvyatkov on 8/31/14.
//  Copyright (c) 2014 Stefan Tsvyatkov. All rights reserved.
//

#import "Smarthings.h"
#import "SMTThingsManager.h"
#import "SMTRulesManager.h"
#import "SMTWebServiceManager.h"

@interface Smarthings ()

@property(strong, nonatomic) SMTThingsManager * thingsManager;
@property(strong, nonatomic) SMTRulesManager * rulesManager;

@end

@implementation Smarthings

-(id)init {
    self = [super init];
    if (self) {
        _thingsManager = [[SMTThingsManager alloc] init];
        _rulesManager = [[SMTRulesManager alloc] init];
    }
    return self;
}

-(void)setDelegate:(id<SmarthingsDelegate>)delegate {
    _delegate = delegate;
    self.rulesManager.delegate = delegate;
    self.thingsManager.delegate = delegate;
}

#pragma mark - SDK Interface methods

- (void)authenticateWithUsername:(NSString *)username
                    andPassword:(NSString *)password {
    // TODO: Implementation needed
}

- (void)forgotPasswordWithEmail:(NSString *)email {
    // TODO: Implementation needed
}


- (void)registerUser:(SMTUser *)user {
    // TODO: Implementation needed
}


- (void)editUser:(SMTUser *)user {
    // TODO: Implementation needed
}


- (SMTUser *)currentUser {
    // TODO: Implementation needed
    return nil;
}


- (void)getThingsList {
    [self.thingsManager getThingsList];
}


- (void)deleteThing:(SMTThing *)thing {
    [self.thingsManager deleteThing:thing];
}


- (void)addThing:(SMTThing *)thing {
    [self.thingsManager addThing:thing];
}


- (void)editThing:(SMTThing *)thing {
    // TODO: Implementation needed
}

- (void)getPropertyValue:(SMTThingProperty *)property {
    [self.thingsManager getPropertyValue:property];
}


- (void)executeAction:(SMTThingAction *)action {
    [self.thingsManager executeAction:action];
}

+ (NSArray *)thingPropertyTypes {
    return [SMTThingsManager thingPropertyTypes];
}


+ (NSArray *)thingActionTypes {
    return [SMTThingsManager thingActionTypes];
}



- (void)getRulesList {
    // TODO: Implementation needed
}


- (void)deleteRule:(SMTRule *)rule {
    // TODO: Implementation needed
}


- (void)addRule:(SMTRule *)rule {
    // TODO: Implementation needed
}


- (void)editRule:(SMTRule *)rule {
    // TODO: Implementation needed
}

+ (NSString *)baseServerURL {
    return [SMTWebServiceManager sharedInstance].baseServerURL;
}

+ (void)setBaseServerURL:(NSString *)baseUrl {
    [SMTWebServiceManager sharedInstance].baseServerURL = baseUrl;
}

@end
